package com.pl.getaway.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.SwitchCompat;

import com.hookgetaway.R;
import com.hookgetaway.utils.nm2;

/* loaded from: classes3.dex */
public class NewUISwitchTextView extends RelativeLayout {
    public LinearLayout a;
    public TextView b;
    public TextView c;
    public TextView d;
    public ImageView e;
    public ImageView f;

    /* renamed from: g, reason: collision with root package name */
    public ImageView f663g;
    public ImageView h;
    public SwitchCompat i;
    public String j;
    public String k;
    public String l;
    public GestureDetector m;
    public boolean n;
    public boolean o;

    public NewUISwitchTextView(Context context) {
        this(context, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void e(View view) {
        f();
    }

    public final void b() {
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.h.getLayoutParams();
        layoutParams.addRule(1, 0);
        if (this.d.getVisibility() == View.VISIBLE) {
            layoutParams.addRule(1, this.d.getId());
        } else {
            layoutParams.addRule(1, this.a.getId());
        }
        this.h.setLayoutParams(layoutParams);
    }

    @SuppressLint("ResourceType")
    public final void c(Context context, AttributeSet attributeSet, int i, int i2) {
        LayoutInflater.from(context).inflate(R.layout.view_new_ui_switch_text_view, this);
        this.a = (LinearLayout) findViewById(R.id.text_layout);
        this.b = (TextView) findViewById(R.id.text_title);
        this.c = (TextView) findViewById(R.id.text_desc);
        this.h = (ImageView) findViewById(R.id.click_guide);
        this.e = (ImageView) findViewById(R.id.image_);
        this.d = (TextView) findViewById(R.id.text_);
        this.f = (ImageView) findViewById(R.id.hint_icon);
        this.f663g = (ImageView) findViewById(R.id.go_icon);
        this.i = (SwitchCompat) findViewById(R.id.switch_in_switch_text_view);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.SwitchTextView, i, i2);
        int indexCount = obtainStyledAttributes.getIndexCount();
        String str = null;
        int i3 = 0;
        int i4 = 0;
        while (true) {
            if (i3 < indexCount) {
                switch (obtainStyledAttributes.getIndex(i3)) {
                    case 0:
                        this.d.setTextSize(1, (int) (isInEditMode() ? 14.0f : nm2.B(obtainStyledAttributes.getDimension(0, nm2.h(14.0f)))));
                        this.b.setTextSize(1, (int) (isInEditMode() ? 14.0f : nm2.B(obtainStyledAttributes.getDimension(0, nm2.h(14.0f)))));
                        continue;
                    case 1:
                        this.d.setTextColor(obtainStyledAttributes.getColor(1, -16777216));
                        continue;
                    case 2:
                        this.i.setChecked(obtainStyledAttributes.getBoolean(2, false));
                        continue;
                    case 3:
                        this.o = true;
                        this.e.setImageResource(obtainStyledAttributes.getResourceId(3, 0));
                        continue;
                    case 4:
                        str = obtainStyledAttributes.getString(4);
                        this.d.setText(str);
                        continue;
                    case 5:
                        this.j = obtainStyledAttributes.getString(5);
                        continue;
                    case 6:
                        this.c.setTextSize(1, (int) (isInEditMode() ? 10.0f : nm2.B(obtainStyledAttributes.getDimension(6, nm2.h(10.0f)))));
                        continue;
                    case 8:
                        this.f663g.setImageResource(obtainStyledAttributes.getResourceId(8, R.drawable.ic_arrow_right));
                        continue;
                    case 9:
                        this.k = obtainStyledAttributes.getString(9);
                        continue;
                    case 10:
                        this.f.setImageResource(obtainStyledAttributes.getResourceId(10, R.drawable.ic_hint_icon));
                        continue;
                    case 11:
                        int dimensionPixelSize = isInEditMode() ? 50 : obtainStyledAttributes.getDimensionPixelSize(11, (int) nm2.h(50.0f));
                        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.f.getLayoutParams();
                        if (layoutParams == null) {
                            layoutParams = new RelativeLayout.LayoutParams(-2, -2);
                        }
                        layoutParams.rightMargin = dimensionPixelSize;
                        this.f.setLayoutParams(layoutParams);
                        continue;
                    case 12:
                        int dimensionPixelSize2 = obtainStyledAttributes.getDimensionPixelSize(12, (int) (isInEditMode() ? 20.0f : nm2.h(20.0f)));
                        RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.e.getLayoutParams();
                        if (layoutParams2 == null) {
                            layoutParams2 = new RelativeLayout.LayoutParams(dimensionPixelSize2, dimensionPixelSize2);
                        }
                        layoutParams2.width = dimensionPixelSize2;
                        layoutParams2.height = dimensionPixelSize2;
                        this.e.setLayoutParams(layoutParams2);
                        continue;
                    case 13:
                        i4 = obtainStyledAttributes.getDimensionPixelSize(13, 0);
                        break;
                    case 14:
                        int dimensionPixelSize3 = obtainStyledAttributes.getDimensionPixelSize(14, (int) (isInEditMode() ? 20.0f : nm2.h(20.0f)));
                        RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) this.e.getLayoutParams();
                        if (layoutParams3 == null) {
                            layoutParams3 = new RelativeLayout.LayoutParams(-2, -2);
                        }
                        layoutParams3.rightMargin = dimensionPixelSize3;
                        this.e.setLayoutParams(layoutParams3);
                        continue;
                    case 16:
                        this.f663g.setVisibility(obtainStyledAttributes.getBoolean(16, false) ? 0 : 8);
                        continue;
                    case 17:
                        obtainStyledAttributes.getBoolean(17, true);
                        continue;
                    case 18:
                        boolean z = obtainStyledAttributes.getBoolean(18, false);
                        this.n = z;
                        this.f.setVisibility(z ? 0 : 8);
                        continue;
                    case 19:
                        this.i.setVisibility(obtainStyledAttributes.getBoolean(19, false) ? 0 : 8);
                        continue;
                }
                this.l = obtainStyledAttributes.getString(15);
                i3++;
            } else {
                obtainStyledAttributes.recycle();
                this.f.setOnClickListener(new View.OnClickListener() { // from class: g.cz0
                    @Override // android.view.View.OnClickListener
                    public final void onClick(View view) {
                        NewUISwitchTextView.this.e(view);
                    }
                });
                if (!TextUtils.isEmpty(this.j)) {
                    g(str, this.j);
                }
                if (!this.o) {
                    this.e.setVisibility(8);
                }
                setHintMargin(i4);
                return;
            }
        }
    }

    public boolean d() {
        return this.i.isChecked();
    }

    @Override // android.view.ViewGroup, android.view.View
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        GestureDetector gestureDetector = this.m;
        if (gestureDetector != null) {
            gestureDetector.onTouchEvent(motionEvent);
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    public final void f() {
//        if (this.l == null) {
//            GuideUtil.e((BaseActivity) nm2.j(getContext()), this.d.getText() != null ? this.d.getText().toString() : null, this.k);
//        } else {
//            GuideUtil.f((BaseActivity) nm2.j(getContext()), this.d.getText() != null ? this.d.getText().toString() : null, this.k, this.l);
//        }
    }

    public void g(CharSequence charSequence, CharSequence charSequence2) {
        this.a.setVisibility(View.VISIBLE);
        this.d.setVisibility(View.GONE);
        this.b.setText(charSequence);
        this.c.setText(charSequence2);
        b();
    }

    public View getSwitchView() {
        return this.i;
    }

    public CharSequence getText() {
        return this.d.getText();
    }

    public void setChecked(boolean z) {
        this.i.setChecked(z);
    }

    public void setClickGuide(boolean z) {
        this.h.setVisibility(z ? View.VISIBLE : View.GONE);
        b();
    }

    public void setHintMargin(int i) {
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.c.getLayoutParams();
        if (layoutParams == null) {
            layoutParams = new LinearLayout.LayoutParams(-2, -2);
        }
        layoutParams.topMargin = i;
        this.c.setLayoutParams(layoutParams);
    }

    public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
        this.i.setOnCheckedChangeListener(onCheckedChangeListener);
    }

    public void setSwitchClickable(boolean z) {
        this.i.setChecked(z);
        this.i.setFocusable(z);
    }

    public void setText(CharSequence charSequence) {
        this.d.setText(charSequence);
    }

    public void setTextColor(int i) {
        this.d.setTextColor(i);
    }

    public void setTextDescColor(int i) {
        this.c.setTextColor(i);
    }

    public void setTextTitleColor(int i) {
        this.b.setTextColor(i);
    }

    public void setUseHint(boolean z) {
        this.n = z;
        this.f.setVisibility(z ? View.VISIBLE : View.GONE);
    }

    public NewUISwitchTextView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public void setText(@StringRes int i) {
        this.d.setText(i);
    }

    public NewUISwitchTextView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        c(context, attributeSet, i, 0);
    }
}